package com.g8.pethospitallearnbackend.mapper;

import com.g8.pethospitallearnbackend.entity.Staff;
import com.g8.pethospitallearnbackend.entity.StaffExample;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface StaffMapper {
    @SelectProvider(type=StaffSqlProvider.class, method="countByExample")
    long countByExample(StaffExample example);

    @DeleteProvider(type=StaffSqlProvider.class, method="deleteByExample")
    int deleteByExample(StaffExample example);

    @Delete({
        "delete from staff",
        "where staff_id = #{staffId,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String staffId);

    @Insert({
        "insert into staff (staff_id, staff_name, ",
        "staff_img, staff_title, ",
        "staff_duty)",
        "values (#{staffId,jdbcType=VARCHAR}, #{staffName,jdbcType=VARCHAR}, ",
        "#{staffImg,jdbcType=VARCHAR}, #{staffTitle,jdbcType=VARCHAR}, ",
        "#{staffDuty,jdbcType=VARCHAR})"
    })
    int insert(Staff record);

    @InsertProvider(type=StaffSqlProvider.class, method="insertSelective")
    int insertSelective(Staff record);

    @SelectProvider(type=StaffSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="staff_id", property="staffId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="staff_name", property="staffName", jdbcType=JdbcType.VARCHAR),
        @Result(column="staff_img", property="staffImg", jdbcType=JdbcType.VARCHAR),
        @Result(column="staff_title", property="staffTitle", jdbcType=JdbcType.VARCHAR),
        @Result(column="staff_duty", property="staffDuty", jdbcType=JdbcType.VARCHAR)
    })
    List<Staff> selectByExample(StaffExample example);

    @Select({
        "select",
        "staff_id, staff_name, staff_img, staff_title, staff_duty",
        "from staff",
        "where staff_id = #{staffId,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="staff_id", property="staffId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="staff_name", property="staffName", jdbcType=JdbcType.VARCHAR),
        @Result(column="staff_img", property="staffImg", jdbcType=JdbcType.VARCHAR),
        @Result(column="staff_title", property="staffTitle", jdbcType=JdbcType.VARCHAR),
        @Result(column="staff_duty", property="staffDuty", jdbcType=JdbcType.VARCHAR)
    })
    Staff selectByPrimaryKey(String staffId);

    @UpdateProvider(type=StaffSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Staff record, @Param("example") StaffExample example);

    @UpdateProvider(type=StaffSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Staff record, @Param("example") StaffExample example);

    @UpdateProvider(type=StaffSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Staff record);

    @Update({
        "update staff",
        "set staff_name = #{staffName,jdbcType=VARCHAR},",
          "staff_img = #{staffImg,jdbcType=VARCHAR},",
          "staff_title = #{staffTitle,jdbcType=VARCHAR},",
          "staff_duty = #{staffDuty,jdbcType=VARCHAR}",
        "where staff_id = #{staffId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(Staff record);
}